"""
面向对象 class
"""
from typing import Union

class Student:
    name = None
    age = None
    # 私有方法以 __ 开头
    __score = None

    # 构造方法
    def __init__(self, name, age=10):
        self.name = name
        self.age = age

    # toString()
    def __str__(self):
        return f"name: {self.name} , age: {self.age}"

    # < 符号比较
    def __lt__(self, other):
        return self.age < other.age

    # <= 符号比较
    def __le__(self, other):
        return self.age <= other.age

    # equals()
    def __eq__(self, other):
        return self.name == other.name

    # 私有方法以 __ 开头
    def __cal_core(self):
        self.__score = 20

    # self 必须写，类对象自身
    def say_hell(self):
        print(f"Hello, I'm {self.name} , {self.age} years old")

    # Union 联合类型注解
    def find_age(self) -> Union[int, str]:
        return self.age


# 继承语法: 子类(父类)
class Student2023(Student):
    # 表示空
    pass


if __name__ == '__main__':
    stu = Student("Wesley")
    stu.say_hell()
    john = Student("John", 10)
    print(stu)
    print(stu > john)
    print(stu >= john)
